package com.wangyi.im.request;

import com.alibaba.fastjson.JSONObject;

public class IMAttachMessageRequest {

    private String from;

    private Integer msgtype;

    private String to;

    private JSONObject attach;

    private String pushcontent;

    private String payload;

    private String sound;

    private Integer save;

    private String option;

    private String isForcePush;

    private IMAttachMessageRequest(String from, int msgtype, String to, JSONObject attach){
        this.from = from;
        this.msgtype = msgtype;
        this.to = to;
        this.attach = attach;
    }

    public static class Builder{

        private String from;

        private int msgtype;

        private String to;

        private String attach;

        private JSONObject attachJson;

        public IMAttachMessageRequest build(){
            if(attach != null && attachJson == null){
                attachJson = new JSONObject();
                attachJson.put("attach", attach);
            }
            return new IMAttachMessageRequest(from, msgtype, to, attachJson);
        }

        public Builder setFrom(String from) {
            this.from = from;
            return this;
        }

        public Builder setMsgtype(int msgtype) {
            this.msgtype = msgtype;
            return this;
        }

        public Builder setTo(String to) {
            this.to = to;
            return this;
        }

        public Builder setAttach(String attach) {
            this.attach = attach;
            return this;
        }

        public Builder setAttachJson(JSONObject attachJson) {
            this.attachJson = attachJson;
            return this;
        }
    }
}
